package com.atguigu.lease.app.controller;

import com.atguigu.lease.app.service.RoomInfoService;
import com.atguigu.lease.model.dto.app.RoomInfoQueryDto;
import com.atguigu.lease.model.result.Response;
import com.atguigu.lease.model.vo.app.RoomDetailVo;
import com.atguigu.lease.model.vo.app.RoomInfoItemVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name="房间信息模块")
@RestController
@RequestMapping("/app/room")
public class RoomInfoController {
    @Autowired
    private RoomInfoService roomInfoService;
    @Operation(summary = "3、根据公寓id查询房间分页列表")
    @GetMapping("pageItemByApartmentId")
    public Response<Page<RoomInfoItemVo>> pageItemByApartmentId(
            @RequestParam Integer current,
            @RequestParam Integer size,
            @RequestParam("id") Long apartmentId
    ){
        RoomInfoQueryDto dto = new RoomInfoQueryDto();
        dto.setCurrent(current);
        dto.setSize(size);
        dto.setApartmentId(apartmentId.toString());
        Page<RoomInfoItemVo> page = roomInfoService.getPage(dto);
        return Response.ok(page);
    }
    @Operation(summary = "2、根据id查询房间详情")
    @GetMapping("getDetailById")
    public Response<RoomDetailVo> getDetailById(@RequestParam Long id) {
        return Response.ok(roomInfoService.getDetailById(id));
    }
    @Operation(summary = "1、条件分页查询房间列表")
    @GetMapping("/pageItem")
    public Response<Page<RoomInfoItemVo>> page(RoomInfoQueryDto roomInfoQueryDto){
        Page<RoomInfoItemVo> page = roomInfoService.getPage(roomInfoQueryDto);
        return Response.ok(page);
    }
}
